<pre><?php


set_include_path(implode(PATH_SEPARATOR, array(
	'C:\Users\MARIA\Downloads\ZendFramework-1.11.11\ZendFramework-1.11.11\library',
	get_include_path()
)));

// ------------------------------------

//require_once('Zend/Sql/Parser.php');
//$parser = Zend_Sql_Parser::factory('MySql');
//$statement = $parser->parse("SELECT `t`.id, fk FROM `table` as t WHERE 1");
//$statement = $parser->parse("SELECT `a`.id, `a`.fk FROM `table_a` as a LEFT JOIN `table_b` as `b` ON `a`.`id`=`b`.`id` WHERE 1");

// ------------------------------------
$dialect   = Zend_Sql_Dialect::SELECT;
$idTable   = new Zend_Sql_Expr_Table('name', 'schema');
$idColumn  = new Zend_Sql_Expr_Column('name', 'table', 'schema');
           //    Zend_Sql_Expr_Identifier('table', 'schema');
$alias     = new Zend_Sql_Expr_Alias($identifier, 'alias');
$alias     = new Zend_Sql_Expr_List(array());
$clause    = new Zend_Sql_Clause_Form('name', 'alias', 'schema');//$identifier
$clause    = new Zend_Sql_Form('name', 'alias', 'schema');//$identifier
$statement = new Zend_Sql_Adapter_Standard_Statement_Select(array(
	'from' => new Zend_Sql_Adapter_Standard_Clause_From(array(
		'expression' => new Zend_Sql_Adapter_Standard_Expression_Table('my_table', 't')
	)),
	'join' => array(),
	'where' => '',
	'group' => '',
	'order' => '',
	'limit' => '',
));

$statement->setClauseFrom(Zend_Sql_Adapter_Standard_Clause_From);
$statement->setClauseWhere(Zend_Sql_Adapter_Standard_Clause_From);
$statement->setClauseOrder(Zend_Sql_Adapter_Standard_Clause_From);
$statement->setClauseLimit(Zend_Sql_Adapter_Standard_Clause_From);

$sql = new Zend_Sql('MySql');
$select = $sql->createStatement('select');
        //$sql->select();
$select->from($from);
$select->where($from);
$select->order($from);
$select->limit(1);

/*
$statement->from(array('t'=>'table'), '*')
	->joinLeft(array('t1'=>'table_1'), 't.id=t1.id', '*')
	->where('t1.id_lang = 1')
	->limit(1, 0);
*/
print_r($statement);

/*
statement:{
	command: 'select',
	table: {
		from: 'table',
		left:  [{table:'table_lang', alias: 'tl', on: {condition
		}, type:'inner'}],
		join:  [],
		inner: [],
		right: [],
	},
	clause: {
		where: 'condition',
		order: 'expr',
		limit: [1, 0]
	}
}

$statement = Zend_Sql_Statement_Select {
	command: 'Select',
	select_expr : Zend_Sql_Expression_List[
		Zend_Sql_Expression_Column('id'),
		Zend_Sql_Expression_Column('fk'),
	],
	from: Zend_Sql_Expression_Table
	from_expr: Zend_Sql_Expression_Table
}

Zend_Sql_Clause_From
Zend_Sql_Expression_Literal
Zend_Sql_Expression_Column & Zend_Sql_Expression_Table extends Zend_Sql_Expression_Identifier 


require_once('Zend/Sql/Parser.php');
$sql = Zend_Sql('MySql');
$select = $sql->parse('SELECT `t`.id, fk FROM `table` as t WHERE 1');
$select = $sql->createStatement('select');
$select->from(array('t'=>'table'), 'id, fk')
		->joinLeft('table_name as t', 'condition_expression')
		->order('expression', 'DESC')
		->where('condition_expression')
		->limit(1, 0);
*/

/*
$statement = new Zend_Sql_Statement_Adapter_MySql_Select();
$statement->from(new Zend_Sql_Statement_Clause_From('table', 'alias'),
				 new Zend_Sql_Statement_Expression_List(array(
				 	new Zend_Sql_Statement_Expression_Identifier('id', 'table', 'schema'),
				 	new Zend_Sql_Statement_Expression_Identifier('fk')
				 ))
	->joinLeft(, )
	->where()
	->limit(1, 0);
*/

/*
require_once('Zend/Sql.php');
//Zend_Sql_Parser::addLoaderPrefix('My_Application_', dirname(__FILE__));
//Zend_Sql_Parser::setDefaultLoader('Zend_Sql_Parser_Adapter_', dirname(__FILE__));

$sql = new Zend_Sql('MySql');
// ----------------------------------------------
$statement = Zend_Sql::load('SELECT * FROM table WHERE 1');
print_r($statement);

$sql = new Zend_Sql($db);
// ----------------------------------------------
$statement = $sql->select();
$statement->from($table, $columns)
       ->join($table, $condition, $columns)
       ->where($condition)
       ->order(array('field_name'), 0)
       ->limit(0, 1);
print_r($statement);// Zend_Db_Statement

$query = 'SELECT * FROM table WHERE 1';
// ----------------------------------------------
$statement = $sql->parse($query);
$statement = $sql->getAdapter()->parse($query);
print_r($statement);
*/

